﻿// -----------------------------------------------------------------------
// <copyright file="FileShare.cs" company="Company">
// Company 2011
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.Runtime.InteropServices;

namespace Company.IO.Interfaces
{
    /// <summary>
    /// <para>
    /// Contains constants for controlling the kind of access other FileStream objects can have to the same file.
    /// </para>
    /// <para>
    /// This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
    /// </para>
    /// </summary>
    [ComVisible(true)]
    [Flags]
    [Serializable]
    public enum FileShare
    {
        /// <summary>
        /// Declines sharing of the current file. 
        /// Any request to open the file (by this process or another process) will fail until the file is closed.
        /// </summary>
        None = System.IO.FileShare.None,

        /// <summary>
        /// Allows subsequent opening of the file for reading. 
        /// If this flag is not specified, any request to open the file for reading 
        /// (by this process or another process) will fail until the file is closed. 
        /// However, even if this flag is specified, additional permissions might still be needed to access the file.
        /// </summary>
        Read = System.IO.FileShare.Read,

        /// <summary>
        /// Allows subsequent opening of the file for writing. 
        /// If this flag is not specified, any request to open the file for writing 
        /// (by this process or another process) will fail until the file is closed. 
        /// However, even if this flag is specified, additional permissions might still be needed to access the file.
        /// </summary>
        Write = System.IO.FileShare.Write,

        /// <summary>
        /// Allows subsequent opening of the file for reading or writing. 
        /// If this flag is not specified, any request to open the file for reading or writing 
        /// (by this process or another process) will fail until the file is closed. 
        /// However, even if this flag is specified, additional permissions might still be needed to access the file.
        /// </summary>
        ReadWrite = System.IO.FileShare.ReadWrite,

        /// <summary>
        /// Allows subsequent deleting of a file.
        /// </summary>
        Delete = System.IO.FileShare.Delete,

        /// <summary>
        /// Makes the file handle inheritable by child processes. This is not directly supported by Win32.
        /// </summary>
        Inheritable = System.IO.FileShare.Inheritable,
    }
}